import serial
import time

servo_cmds = [
    "at+servo=550 750 750 750 750  820\r\n",
    "at+servo=600 750 750 750 750  840\r\n",
    "at+servo=650 750 750 750 750  860\r\n",
    "at+servo=700 750 750 750 750  880\r\n",
    "at+servo=750 750 750 750 750  900\r\n",
    "at+servo=800 750 750 750 750  920\r\n",
    "at+servo=850 750 750 750 750  940\r\n",
    "at+servo=900 750 750 750 750  960\r\n",
    "at+servo=950 750 750 750 750  980\r\n",
    "at+servo=900 750 750 750 750 1000\r\n",
    "at+servo=850 750 750 750 750 1020\r\n",
    "at+servo=800 750 750 750 750 1040\r\n",
    "at+servo=750 750 750 750 750 1060\r\n",
    "at+servo=700 750 750 750 750 1080\r\n",
    "at+servo=650 750 750 750 750 1100\r\n",
    "at+servo=600 750 750 750 750 1120\r\n",
    "at+servo=550 750 750 750 750 1140\r\n",
    "at+servo=600 750 750 750 750 1160\r\n",
    "at+servo=650 750 750 750 750 1180\r\n",
]

try:
    ser = serial.Serial('COM4', 9600, timeout=0)

    ser.write("at+servo\r\n".encode())
    for i in range(20):
        for cmd in servo_cmds:
            ser.write(cmd.encode())
            print(cmd)
            time.sleep(0.1)


    ser.close()
    print('done')

except Exception as e:
    print("Exception: ", e)
